//
//  STUserCenter.swift
//  iPhone
//
//  Created by Toj on 3/31/23.
//

import Foundation

class STUserCenter: NSObject {
    static let `default` = STUserCenter()
    private override init() { }
    
    func setupUser(info: STUserModel) {
        _user = info
    }
    
    func clear() {
        _user = nil
    }
    
    private var _user: STUserModel? { didSet {
        guard let model = _user else {
            token = ""
            isLogin = false
            return
        }
        
        token = model.token
        countryId = model.countryId
    } }
    
    private var _isLogin = false
    var isLogin: Bool {
        set {
            _isLogin = newValue
        }
        
        get {
            return _isLogin
        }
    }
    
    private var _token = ""
    private(set) var token: String {
        set {
            _token = newValue
        }
        
        get {
            return _token
        }
    }
    
    private var _countryId = 0
    private(set) var countryId: Int {
        set {
            _countryId = newValue
        }
        
        get {
            return _countryId
        }
    }
}
